/**
 * 
 */
package inet.app.model.cau;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Nguyen Le Chau
 *
 */
public class CauTable implements Serializable{
	List<CauCell> cellList;
	
	public CauTable(){
		cellList = new ArrayList<CauCell>();
	}
	
	public void addCell(CauCell cell){
		if(cell!=null)
			cellList.add(cell);
	}
	
	//0< pos1 < 10
	public CauCell getCell(int pos1, int pos2){
		if(cellList!=null &&  cellList.size()>0){
			for(CauCell cell:cellList){
				if(cell.getValueposition1()==pos1 && cell.getValueposition2()==pos2){
					return cell;
				}
			}
		}
		return null;
	}
	
	
	/**
	 * @param value: Gia tri cau ~ Lo cua CauCell
	 * @return CauCell
	 */
	public CauCell getCell(int value){
		//int vInt = Integer.parseInt(value);
		if(cellList!=null &&  cellList.size()>0){
			for(CauCell cell:cellList){
				if(cell.getValue() == value){
					return cell;
				}
			}
		}
		return null;
	}
	
	
	public boolean hasCell(int val){
		for(CauCell i : cellList){
			if(i.getValue()==val)
				return true;
		}
		return false;
	}
	
	
			
	/*public CauCell getCell(int rowNum, int colNum){
		if(cellList!=null &&  cellList.size()>0){
			for(CauCell cell:cellList){
				if(cell.colNumber==colNum && cell.rowNumber==rowNum){
					return cell;
				}
			}
		}
		return null;
	}*/
	
}
